<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的留言</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>我的留言</legend>
</fieldset>

<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title">
        <%-- <li class="layui-this"><a href="http://localhost:8080/OnlineExam/admin/leaveword?m=findmyleave">我的留言</a></li>--%>
        <li class="layui-this">我的留言</li>
        <li><a href="#">我的回复</a></li>
        <li><a href="#">回复我的</a></li>
    </ul>
    <div class="layui-tab-content" style="height: 100px;">

        <div class="layui-tab-item layui-show">
            <table class="layui-table" id="myleavelist" lay-filter="myleavelist">
                <%-- <thead>
                 <tr>
                   <th>留言id</th>
                   <th>留言内容</th>
                   <th>留言时间</th>
                   <th>操作</th>
                 </tr>
               </thead>
               <tbody id="myleavelist">
             <c:forEach items="${myleavelist}" var="myleave">
                   <tr>
                       <td>${myleave.leaveWord_id}</td>
                       <td>${myleave.leaveWord_content}</td>
                       <td>${myleave.leaveWord_date}</td>
                       <td><button class="layui-btn btndelmyleave"  dataid='${myleave.leaveWord_id}'>删除</button></td>
                   </tr>
               </c:forEach>
                </tbody>--%>
            </table>
            <script type="text/html" id="barDemo1">
                <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="del">删除</a>
            </script>
        </div>

        <div class="layui-tab-item">
            <table class="layui-table" id="myanswerlist" lay-filter="myanswerlist">
                <%--  <thead>
                  <tr>
                    <th>回复id</th>
                    <th>回复内容</th>
                    <th>回复留言</th>
                    <th>回复对象</th>
                    <th>回复时间</th>
                    <th>操作</th>
                  </tr>
                </thead>
                <tbody id="myanswerlist">
              <c:forEach items="${myleaveanswerlist}" var="myleaveanswer">
                    <tr>
                        <td>${myleaveanswer.answer_id}</td>
                        <td>${myleaveanswer.answer_content}</td>
                        <td>${myleaveanswer.leaveWord_id}</td>
                        <td>${myleaveanswer.user_name}</td>
                        <td>${myleaveanswer.answer_date}</td>
                        <td><button class="layui-btn btndelmyleaveanswer"  dataid='${myleaveanswer.answer_id}'>删除</button></td>
                    </tr>
                </c:forEach>
                </tbody>--%>
                <script type="text/html" id="barDemo2">
                    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="del">删除</a>
                </script>
            </table>
        </div>

        <div class="layui-tab-item">
            <table class="layui-table" id="tomeanswerlist" lay-filter="tomeanswerlist">
                <%--  <thead>
                  <tr>
                    <th>回复id</th>
                    <th>回复内容</th>
                    <th>回复留言</th>
                    <th>回复时间</th>
                  </tr>
                </thead>
                <tbody id="tomeanswerlist">
              <c:forEach items="${tomeanswerlist}" var="tomeanswer">
                    <tr>
                        <td>${tomeanswer.answer_id}</td>
                        <td>${tomeanswer.answer_content}</td>
                        <td>${tomeanswer.leaveWord_id}</td>
                        <td>${tomeanswer.answer_date}</td>
                    </tr>
                </c:forEach>
                </tbody>--%>
            </table>
        </div>
    </div>
</div>

</body>
<script src="../layui/layui.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    var layer;
    layui.use(['element', 'form', 'layedit', 'laydate', 'laypage', 'layer', 'table'], function () {
        var $ = layui.jquery,
            element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
        var form = layui.form,
            layer = layui.layer,
            layedit = layui.layedit,
            laydate = layui.laydate;
        var laypage = layui.laypage,
            layer = layui.layer;
        var table = layui.table;

        //显示所有 我的留言
        table.render({
            elem: '#myleavelist',
            url: '/OnlineExam/admin/leaveword?m=findmyleave',
            page: true,
            cols: [[
                {field: 'leaveWord_id', title: '留言id', width: '10%', sort: true, fixed: 'left'}
                , {field: 'leaveWord_content', title: '留言内容', width: '40%', sort: true, fixed: 'left'}
                , {field: 'leaveWord_date', title: '留言时间', width: '20%', sort: true, fixed: 'left'}
                , {fixed: 'right', width: '30%', align: 'center', toolbar: '#barDemo1'}
            ]]

        })
        //显示所有 我的回复
        table.render({
            elem: '#myanswerlist',
            url: '/OnlineExam/admin/leaveword?m=findmyanswer',
            page: true,
            cols: [[
                {field: 'answer_id', title: '回复id', width: '10%', sort: true, fixed: 'left'}
                , {field: 'answer_content', title: '回复内容', width: '30%', sort: true, fixed: 'left'}
                , {field: 'leaveWord_id', title: '回复留言', width: '10%', sort: true, fixed: 'left'}
                , {field: 'user_name', title: '回复对象', width: '10%', sort: true, fixed: 'left'}
                , {field: 'answer_date', title: '回复时间', width: '10%', sort: true, fixed: 'left'}
                , {fixed: 'right', width: '30%', align: 'center', toolbar: '#barDemo2'}
            ]]

        })
        //显示所有 对我的回复
        table.render({
            elem: '#tomeanswerlist',
            url: '/OnlineExam/admin/leaveword?m=findtomeanswer',
            page: true,
            cols: [[
                {field: 'answer_id', title: '回复id', width: '10%', sort: true, fixed: 'left'}
                , {field: 'answer_content', title: '回复内容', width: '40%', sort: true, fixed: 'left'}
                , {field: 'leaveWord_id', title: '回复留言', width: '10%', sort: true, fixed: 'left'}
                , {field: 'answer_date', title: '回复时间', width: '10%', sort: true, fixed: 'left'}
            ]]

        })

        table.on('tool(myleavelist)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data //获得当前行数据
                , layEvent = obj.event; //获得 lay-event 对应的值
            console.log("当前行数据：" + data)
            if (layEvent === 'del') {
                layer.confirm("您确定删除留言" + data.leaveWord_id + "吗？", {btn: ['确定', '取消'], title: "提示"}, function (index) {
                    console.log("已删除--》" + data.leaveWord_id);
                    location.href = "http://localhost:8080/OnlineExam/admin/leaveword?m=delmyleave&leaveWord_id=" + data.leaveWord_id;
                    layer.close(index);
                })
            }
        });

        table.on('tool(myanswerlist)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data //获得当前行数据
                , layEvent = obj.event; //获得 lay-event 对应的值
            console.log("当前行数据：" + data)
            if (layEvent === 'del') {
                layer.confirm("您确定删除回复" + data.answer_id + "吗？", {btn: ['确定', '取消'], title: "提示"}, function (index) {
                    console.log("已删除--》" + data.answer_id);
                    location.href = "http://localhost:8080/OnlineExam/admin/leaveword?m=delmyanswer&answer_id=" + data.answer_id;
                    layer.close(index);
                })
            }
        });


    });
    /*     //删除我的留言回复 加事件
         $(".btndelmyleaveanswer").click(function(){
             var answer_id=$(this).attr("dataid");
             layer.confirm('您确定删除该用户？',{btn:['确定','取消'],title:"提示"},function(index){
                 console.log("已删除--》"+answer_id);
                 location.href="http://localhost:8080/OnlineExam/admin/leaveword?m=delmyanswer&answer_id="+answer_id;
                 layer.close(index);
             });
         });

         //删除我的留言 加事件
         $(".btndelmyleave").click(function(){
             var leaveWord_id=$(this).attr("dataid");
             layer.confirm('您确定删除该用户？',{btn:['确定','取消'],title:"提示"},function(index){
                 console.log("已删除--》"+leaveWord_id);
                 location.href="http://localhost:8080/OnlineExam/admin/leaveword?m=delmyleave&leaveWord_id="+leaveWord_id;
                 layer.close(index);
             });
         });
     });*/
</script>

</html>